package com.li.manage.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.li.manage.constant.Constants;
import com.li.manage.model.User;

public class LoginInterceptor extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler)
			throws Exception {
		super.preHandle(req, resp, handler);
		User user = (User) req.getSession().getAttribute(Constants.USER_LOGIN_STR);
		if(user == null){
			resp.sendRedirect("/login/toLogin");
			return false;
		}else{
			return true;
		}
		
	}

	
}
